package com.artisan.provider.service.impl;

import com.artisan.provider.domain.ZgCouponIntegralExchange;
import com.artisan.provider.dto.ZgCouponIntegralExchangeDto;
import com.artisan.provider.mapper.ZgCouponIntegralExchangeMapper;
import com.artisan.provider.service.ZgCouponIntegralExchangeService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ZgCouponIntegralExchangeServiceImpl implements ZgCouponIntegralExchangeService {

    @Autowired
    ZgCouponIntegralExchangeMapper zgCouponIntegralExchangeMapper;

    @Override
    public List<ZgCouponIntegralExchange> findAll(ZgCouponIntegralExchangeDto zgCouponIntegralExchangeDto, int page, int limit) {
        if(page > 0 && limit > 0){
            PageHelper.startPage(page,limit);
        }
        return zgCouponIntegralExchangeMapper.findAll(zgCouponIntegralExchangeDto);
    }

    @Override
    public int zgCouponIntegralExchangeAdd(ZgCouponIntegralExchange zgCouponIntegralExchange) {
        int i = 0;
        try {
            return zgCouponIntegralExchangeMapper.insertSelective(zgCouponIntegralExchange);
        }catch (Exception e){
            return i;
        }
    }

    @Override
    public int zgCouponIntegralExchangeUpdate(ZgCouponIntegralExchange zgCouponIntegralExchange) {
        int i = 0;
        try {
            return zgCouponIntegralExchangeMapper.updateByPrimaryKeySelective(zgCouponIntegralExchange);
        }catch (Exception e){
            return i;
        }
    }

    @Override
    public int zgCouponIntegralExchangeDelete(int id) {
        return zgCouponIntegralExchangeMapper.deleteByPrimaryKey(id);
    }

}
